package task1;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Main {
	
	private static final Logger logger = Logger.getLogger(Main.class);

	public static void main(String[] args) {

		PropertyConfigurator.configure("log4j.properties");

		logger.debug("START");
		
		logger.debug("new CreateXMLTemplate");
		CreateXMLTemplate createXML = new CreateXMLTemplate("digits_template.txt", "digits_template.xml");
		createXML.setXMLTemplate();
		
		logger.debug("new Loader");
		Loader l = new Loader("input.txt");
		
		logger.debug("new TextTemplateFactory");
		ITemplateFactory f = new TextTemplateFactory("digits_template.xml");
		
		logger.debug("new TextSerializer");
		Serializer s = new TextSerializer(f, "output.txt");
		
		logger.debug("Start serialize()");
		for (DataItem i : l.loadData()) {
			logger.debug("DataItem : " + i.getValue());
			s.serialize(i);
		}
		logger.debug("Stop serialize()");
		
		logger.debug("STOP");

	}
}